package com.afalon.cloud.contracts.finance;

import java.net.URI;
import java.util.List;

import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.jdo.annotations.IdGeneratorStrategy;
import javax.jdo.annotations.PersistenceCapable;
import javax.jdo.annotations.Persistent;
import javax.jdo.annotations.PrimaryKey;

import com.google.appengine.api.datastore.Key;
import com.google.appengine.api.datastore.KeyFactory;

@PersistenceCapable
@XmlRootElement(name = "chart")
@XmlAccessorType(XmlAccessType.NONE)
public class Chart 
{
	
	@PrimaryKey
	@Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
    private Key chartKey;
	
	@XmlElement
	@Persistent
	private String name;
	
	@Persistent(mappedBy = "chart")
    private List<Account> accounts;
	
	@Persistent(mappedBy = "chart")
    private List<Transaction> transactions;

	@XmlElement(name="charturi")
	public URI chartUri;
	
	public Chart() 
	{
		
	}

	public Key getChartKey() {
		return chartKey;
	}
	
	/* @XmlElement */ 
	public String getChartId() {
		return KeyFactory.keyToString(this.getChartKey());
	}

	public void setName(String value) {
		name = value;
	}

	public String getName() {
		return name;
	}

	public List<Account> getAccounts() {
		return accounts;
	}

	public List<Transaction> getTransactions() {
		return transactions;
	}
	
}
